<template>
  <el-dialog  :visible.sync="isShow" center class="earnings-deduction">
    <el-table class="detail-table" :data="deduction" border max-height="250" style="width: 100%">
      <el-table-column align="center" prop="deduction_price" show-overflow-tooltip label="金额">
        <template slot-scope="scope">
          <span class="font_danger">{{ scope.row.deduction_price }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="原因" show-overflow-tooltip></el-table-column>
      <el-table-column align="center" prop="appeal" show-overflow-tooltip label="结果">
        <template slot-scope="scope">
          <template v-if="scope.row.appeal">
            <span>{{ scope.row.appeal.status | deductionsAppeal }}</span>
          </template>
          <span v-else>未申诉</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            :disabled="scope.row.appeal != null"
            @click="deductionAppeal(scope.row)"
          >申诉</el-button>
        </template>
      </el-table-column>
    </el-table>
    <deductionAppeal ref="deductionAppeal" @refresh="refresh"></deductionAppeal>
  </el-dialog>
    
</template>

<script>
import deductionAppeal from "./deduction-appeal";
export default {
  components: {
    deductionAppeal
  },
  data() {
    return {
      deduction: [],
      detail: null,
      settlement_id: null,
      isShow: false
    };
  },
  methods: {
    deductionAppeal(row) {
      this.$refs['deductionAppeal'].show(row)
    },
    refresh() {
      this.is_show = false;
      this.$emit("refresh");
    },
    show(data) {
      this.settlement_id = data.id;
      this.getInfo();
      this.isShow = true;
    },
    getInfo() {
      this.$axios.get(`api/settlement/${this.settlement_id}`).then(res => {
        if (res.data.code == 200) {
          this.detail = res.data.data;
          this.deduction = res.data.data.final.order.deduction
          if (this.detail.final) {
            this.order_number = this.detail.final.order_number;
          }
          if (this.deduction) {
          } else {
            this.$alert("该结算暂无扣款详情！", "提示", {
              confirmButtonText: "确定",
              callback: action => {}
            });
          }
        } else {
          this.$alert(res.data.message, "提示", {
            confirmButtonText: "确定",
            center: true,
            type: "warning",
            callback: action => {}
          });
        }
      });
    }
  }
};
</script>

<style>
</style>